const Koa = require('koa');
const Router = require('koa-router'); // 引入koa-router
var cors = require('koa-cors');
const bodyParser = require('koa-bodyparser');
const KoaStatic = require('koa-static');

const app = new Koa(); // 创建koa应用
const router = new Router(); // 创建路由，支持传递参数

app.use(cors({
    credentials: true
}));
app.use(bodyParser({
    enableTypes: ['json', 'form', 'text']
}));
app.use(KoaStatic('./images/', {
    maxage: 60000
}))
router.post("/ajax", async (ctx)=>{
    //获取表单的数据
    ctx.body= await ctx.request.body;
    console.log(ctx.request.body)
})


app.use(router.routes());

app.listen(3000);

